MESSAGEBOX("VAI COMECAR")
USE D:\MaisEscola_Path\Impacto\Impacto_Geral\Dados\AVA_TAB_QUEST2.DBF IN 1 ALIAS QUEST2
USE D:\MaisEscola_Path\Impacto\Impacto_Geral\Dados\SEC_TAB_ALUANO.DBF IN 2 ALIAS ALUANO

WLIDOS=0
WGRAVA=0
WPER  =0
SELECT QUEST2
GO TOP
WTOT=RECCOUNT()
DO WHILE NOT EOF()
   WCHAVE=STR(QUEST2.ESCOLA,3)+QUEST2.ANO+QUEST2.SEQANO+STR(QUEST2.MATRIC,7)

   WLIDOS=WLIDOS+1
   WPER  =(WLIDOS/WTOT)*100
   WAIT WINDOW "Lendo..."+str(WLIDOS,7)+"    Percentual..."+str(WPER,7) NOWAIT
   
   WGRAVA=WGRAVA+1
   SELECT QUEST2
   REPLACE CURSO WITH "" ,;
           TURMA WITH ""

*!*	   SELECT ALUANO
*!*	   SET ORDER TO ALUANO1 && STR(escola,3)+ano+seqano+STR(matric,7)
*!*	   SEEK WCHAVE
*!*	   IF NOT EOF()
*!*	      WGRAVA=WGRAVA+1
*!*	      WCURSO=ALUANO.CURSO
*!*	      WTURMA=ALUANO.TURMA
*!*	      
*!*	      SELECT QUEST2
*!*	      REPLACE CURSO WITH WCURSO ,;
*!*	              TURMA WITH WTURMA
*!*	   ENDIF
   SELECT QUEST2
   SKIP IN "QUEST2"
ENDDO
WAIT CLEAR

MESSAGEBOX("FINAL")
MESSAGEBOX("LIDOS: "+STR(WLIDOS,7)+CHR(13)+;
           "GRAVA: "+STR(WGRAVA,7))